package com.appspot.zcmjqm.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.appspot.zcmjqm.service.ConsultService;
import com.appspot.zcmjqm.service.ProductService;
import com.appspot.zcmjqm.service.ServiceService;

@Controller
@RequestMapping("/home")
public class HomeControllerWebMVCImpl implements HomeController {
	
	@Autowired
	private ProductService productService;
	
	@Autowired
	private ServiceService serviceService;
	
	@Autowired
	private ConsultService consultService;

	@RequestMapping("/show.do")
	public ModelAndView displayHome() {
		ModelAndView mav = new ModelAndView();
		mav.addObject("productCategories", productService.getAllCategories());
		mav.addObject("serviceCategories", serviceService.getAllCategories());
		mav.addObject("consultCategories", consultService.getAllCategories());
		mav.setViewName("index");
		return mav;
	}

	public void setProductService(ProductService productService) {
		this.productService = productService;
	}

	public void setServiceService(ServiceService serviceService) {
		this.serviceService = serviceService;
	}

	public void setConsultService(ConsultService consultService) {
		this.consultService = consultService;
	}
	
}